<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            二当家的Lay1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/static/css/x-admin.css" media="all">
        <link rel="stylesheet" href="/static/lib/layui/css/layui.css"  media="all">
        <link rel="stylesheet" href="/static/cityJSON.txt"  media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" id="contactForm">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label" method="post">
                        	姓名：
                    </label>
                    <div class="layui-input-inline">
                        <input type="hidden" name="orgIdStr" value=${orgInfo.id }>
						<input type="text" name="name" id="orgName" lay-verify="required"
                        autocomplete="off" class="layui-input" value=${contact.name}> <span id="nameSpan"
										style="color: red;">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        	性别：
                    </label>
                    <div class="layui-input-inline">
                        <input id="boy" type="radio" name="sex" value="男" title="男" checked="">
      					<input id="girl" type="radio" name="sex" value="女" title="女">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        	职务：
                    </label>
                    <div class="layui-input-inline">
                        <input lay-verify="required" type="text" name="job" class="layui-input" value=${contact.job}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="role" class="layui-form-label">
                        	手机：
                    </label>
                    <div class="layui-input-inline">
                      <input type="text" name="phone" lay-verify="required" class="layui-input" value=${contact.phone}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        	联系人电话：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="tel" lay-verify="required" class="layui-input" value=${contact.tel}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	邮箱：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="email" class="layui-input" value=${contact.email}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	QQ：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="qq" class="layui-input" value=${contact.qq}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                          	微信：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="wechat" class="layui-input" value=${contact.wechat}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                          	地址：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="address" class="layui-input" value=${contact.address}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	重要等级：
                    </label>
                    <div class="layui-input-inline">
                        <select name="important" lay-filter="important" > 
										<option />一般
										<option />重要
										<option />很重要
										<option />非常重要
									</select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	跟进状态：
                    </label>
                    <div class="layui-input-inline">
                        <select name="busStatus" lay-filter="important" > 
										<option />未处理
										<option />无效
										<option />有效
										<option />放弃
									</select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	经办人：
                    </label>
                    <div class="layui-input-inline">
                        <select name="operatorName">
							<#list staffList as staff>
							<#if trade.operatorId=staff.id>
							<option value=${staff.id } selected>${staff.name }</option> 
							<#else>
							<option value=${staff.id }>${staff.name }</option> 
							</#if>
							</#list>
						</select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	信息来源：
                    </label>
                    <div class="layui-input-inline">
                        <textarea name="infoSource" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	创建时间：
                    </label>
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="自定义日期格式" name="dateStr"
                        onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" value='${trade.buyDateStr}'>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        	备注：
                    </label>
                    <div class="layui-input-inline">
                        <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">
                        确认提交
                    </button>
                </div>
            </form>
        </div>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/static/js/x-layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/cityJSON.txt"></script>
		<script type="text/javascript">
		$(document).ready(function() {
    		if('${contact.sex}'=='女'){
    			$("#girl").attr("checked","true");
    		}else{
    			$("#boy").attr("checked","true");
    		}
		    $("[name='important']").val('${contact.important}');
		    $("[name='operatorName']").val('${contact.operatorName}');
		    $("[name='infoSource']").val('${contact.infoSource}');
		    $("[name='remark']").val('${contact.remark}');
		    
    		$("[name='name']").blur(function(){
    			if($(this).val()==''){
    				$("#nameSpan").html("联系人名称不能为空");
    				$("#nameSpan").css('color','red');
    			}else{
    				$("#nameSpan").html("");
    			}
        	});
    		$("[name='job']").blur(function(){
    			if($(this).val()==''){
    				$("#jobSpan").html("职务不能为空");
    				$("#jobSpan").css('color','red');
    			}else{
    				$("#jobSpan").html("");
    			}
        	});
    		$("[name='phone']").blur(function(){
    			if($(this).val()==''){
    				$("#phoneSpan").html("手机不能为空");
    				$("#phoneSpan").css('color','red');
    			}else{
    				$("#phoneSpan").html("");
    			}
        	});
    		$("[name='tel']").blur(function(){
    			if($(this).val()==''){
    				$("#telSpan").html("电话不能为空");
    				$("#telSpan").css('color','red');
    			}else{
    				$("#telSpan").html("");
    			}
        	});
    		$("[name='email']").blur(function(){
    			if($(this).val()==''){
    				$("#emailSpan").html("邮箱不能为空");
    				$("#emailSpan").css('color','red');
    			}else{
    				$("#emailSpan").html("");
    			}
        	});
    		$(".redStar").change(function(){
    			$("#submitbt").attr('disabled',false);
    			$(".redStar").each(function(){
    				if($(this).val()==""){
    					$("#submitbt").attr('disabled',true);
    				}
    			});
    		});
    		$("#submitbt").click(function(){
    			if('${contact}'==''){
    				if(confirm("确认添加？'${contact}'")){
    					$("#basic_validate").attr("action","addContactAction");
    					$("#basic_validate").submit();
    				}
    			}else{
    				if(confirm("确认修改？")){
    					$("#basic_validate").attr("action","updateContactAction");
    					$("#basic_validate").submit();
    				}
    			}
    		});
    	});
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
            
              //自定义验证规则
              form.verify({
                nikename: function(value){
                  if(value.length < 5){
                    return '昵称至少得5个字符啊';
                  }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,repass: function(value){
                    if($('#L_pass').val()!=$('#L_repass').val()){
                        return '两次密码不一致';
                    }
                }
              });
              //监听提交
              form.on('submit(add)', function(data){
            	  if ('${contact}' == '') {
            		  $.ajax({
            			  data:$('#contactForm').serialize(),
            			  url:"addContactAction",
            		  	  type:"post",
            		  	  success:function(){
            		  		layer.alert("增加成功", {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                parent.location.reload();
                            });
            		  	  }
            		  });
            		  
					} else {
						$.ajax({
							  data:$('#contactForm').serialize(),
	            			  url:"updateContactAction",
	            		  	  type:"post",
	            		  	  success:function(){
	            		  		layer.alert("修改成功", {icon: 6},function () {
	                                // 获得frame索引
	                                var index = parent.layer.getFrameIndex(window.name);
	                                //关闭当前frame
	                                parent.layer.close(index);
	                                parent.location.reload();
	                            });
	            		  	  },
							  
	            		  });
						
					}
                return false;
              });
            });
            layui.use('laydate', function(){
            	  var laydate = layui.laydate;
            	  
            	  var start = {
            	    min: laydate.now()
            	    ,max: '2099-06-16 23:59:59'
            	    ,istoday: false
            	    ,choose: function(datas){
            	      end.min = datas; //开始日选好后，重置结束日的最小日期
            	      end.start = datas //将结束日的初始值设定为开始日
            	    }
            	  };
            	  
            	  var end = {
            	    min: laydate.now()
            	    ,max: '2099-06-16 23:59:59'
            	    ,istoday: false
            	    ,choose: function(datas){
            	      start.max = datas; //结束日选好后，重置开始日的最大日期
            	    }
            	  };
            	  
            	  document.getElementById('LAY_demorange_s').onclick = function(){
            	    start.elem = this;
            	    laydate(start);
            	  }
            	  document.getElementById('LAY_demorange_e').onclick = function(){
            	    end.elem = this
            	    laydate(end);
            	  }
            	  
            	});
        </script>
        <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
        </script>
    </body>

</html>